package gupao.concurrency.kms;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

@Slf4j
@Getter @Setter
public class RequestModel {

    private LinkedHashMap<String,String> paramMap = new LinkedHashMap<>();
    private String signature;
    private String id;

    public RequestModel(LinkedHashMap<String, String> paramMap, String signature) {
        this.paramMap = paramMap;
        this.signature = signature;
    }

    public String getJoinedReqParamStr(){
        StringBuilder sb = new StringBuilder();
        getParamMap().forEach((key,val) -> {
            sb.append(key).append("=").append(val).append("&");
        });

        return sb.substring(0,sb.length()-1);
    }
}
